package cn.rubintry.bug.hunting.common.extension

import com.google.gson.Gson
import com.google.gson.reflect.TypeToken


inline fun <reified T> String?.toObject(): T {
    try {
        return Gson().fromJson(this , object : TypeToken<T>(){}.type)
    }catch (e: Exception){
        throw IllegalArgumentException("请传入正确的json: ${e.message}")
    }
}

fun Any?.toJson(): String {
    return Gson().toJson(this)
}